#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define FILE_NAME "log.txt"

int main()
{
   //char buf[1024];
   //ssize_t s = read(0, buf, 1024);
   //if(s)
   //{
   //    buf[s - 1] = 0;
   //    printf("echo:%s\n", buf);
   //    printf("s: %d\n", s);
   //    ssize_t s2 = write(1, buf, strlen(buf));
   //    printf("s2: %d", s2);
   //}
   //close(0);
    
    close(1);
    int fd = open(FILE_NAME, O_CREAT|O_WRONLY|O_TRUNC, 0666);
    if(fd < 0)
    {
        perror("open");
        return 1;
    }

    printf("fd: %d\n", fd);
    return 0;
}
